<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('服务对话列列表')"/>
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
<div class="container-div">

    <div class="btn-group-sm" id="toolbar" role="group">

        <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:service:export">
            <i class="fa fa-download"></i> 导出
        </a>
    </div>
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>通话ID：</label>
                            <input type="text" name="serviceId"/>
                        </li>
                        <li>
                            <label>开始时间：</label>
                            <input type="text" class="form-control" name="beginTime" id="beginTime"
                                   placeholder="呼叫开始时间" />
                        </li>
                        <li>
                            <label>开始结束：</label>
                            <input type="text" class="form-control" name="endTime" id="endTime"
                                   placeholder="呼叫结束时间" />
                        </li>
                        <li>
                            <label>客户号码：</label>
                            <input type="text" name="fromnum"/>
                        </li>

                        <li>
                            <label>选择坐席：</label>
                            <select  class="form-control" name="agentid" th:with="type=${@dict.getType('sys_user_kf')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                </option>
                            </select>
                        </li>
                        <li>
                            <label>接听状态：</label>
                            <select class="form-control" name="state">
                                <option value="">全部</option>
                                <option value="3">接通</option>
                                <option value="5">未接通</option>
                            </select>
                        </li>
                        <li>
                            <label>呼叫类型：</label>
                            <select class="form-control" name="isinside">
                                <option value="">请选择呼叫类型</option>
                                <option value="2">呼入</option>
                                <option value="3">呼出</option>
                            </select>
                        </li>
                        <li>
                            <label>满意度：</label>
                            <select class="form-control" name="satisfaction">
                                <option value="">请选择满意度类型</option>
                                <option value="3">一般</option>
                                <option value="5">不满意</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" style="margin-right:10px" onclick="$.table.search()"><i
                                    class="fa fa-search" ></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div><th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    layui.use('laydate', function () {

        function getMonthStart() {
            var now = new Date(); // 获取当前日期时间
            var monthStart = new Date(now.getFullYear(), now.getMonth(), 1); // 获取本月第一天的日期时间
            var monthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59); // 获取本月最后一天的日期时间（时间为23:59:59）
            return monthStart;
        }

        function getMonthEnd() {
            var now = new Date(); // 获取当前日期时间
            var monthStart = new Date(now.getFullYear(), now.getMonth(), 1); // 获取本月最后一天的日期时间
            var monthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59); // 获取本月最后一天的日期时间（时间为23:59:59）
            return monthEnd;
        }

        layui.laydate.render({
            elem: '#beginTime',
            theme: 'molv',
            trigger: 'click',
            value: getMonthStart(),
            type: 'datetime'
        })

        layui.laydate.render({
            elem: '#endTime',
            theme: 'molv',
            value: getMonthEnd(),
            trigger: 'click',
            type: 'datetime'
        })
    });
</script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:service:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:service:remove')}]];
    var prefix = ctx + "system/service";

    $(function () {
        var options = {
            url: prefix + "/listTel",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "服务对话列",
            columns: [{
                checkbox: true
            },
                {
                    field: 'serviceId',
                    title: '通话会话Id',
                    visible: false
                },
                {
                    field: 'beginTime',
                    title: '呼叫发起时间'
                },
                {
                    field: 'endTime',
                    title: '呼叫挂断时间'
                },
                {
                    field: 'customerid',
                    title: '客户姓名',
                    formatter: function (value, row, index) {
                        if (row.customerid == '-'){
                            return '未知客户'
                        }else{
                            return  '未知客户'
                        }
                    }
                },
                {
                    field: 'fromnum',
                    title: '客户电话'

                },
                {
                    field: 'cname',
                    title: '对方归属地'
                },
                {

                    field: 'state',
                    title: '接听状态',
                    formatter: function (value, row, index) {
                        if (row.state == '5'){
                            return '<font color="red">未接通 </font>'
                        }else{
                            return  '接通'
                        }
                    }
                },
                {
                    field: 'isinside',
                    title: '呼叫类型',
                    formatter: function (value, row, index) {
                        if (row.isinside == "2"){
                            return '呼入'
                        }
                        if  (row.isinside == "3") {
                            return '呼出'
                        }
                    }
                },
                {
                    field: 'customerid',
                    title: '通话时长',
                    formatter: function (value, row, index) {

                            if (row.state == '5') {
                                return 0 + '分' + 0 + '秒';
                            } else{
                                return  row.minutesDifference + '分' + row.secondsDifference + '秒';
                            }


                    }
                },
                {
                    field: 'servicetype',
                    title: '排队总时长',

                    formatter: function (value, row, index) {

                        if (row.state == '5') {
                            return 0 + '分' + 0 + '秒';
                        } else{
                            return  row.minutesDifference + '分' + row.secondsDifference + '秒';
                        }
                    }

                },
                {
                    field: 'agentid',
                    title: '服务坐席'

                },
                {
                    field: 'satisfaction',
                    title: '满意度',
                    formatter: function (value, row, index) {
                         if (row.satisfaction == "2"){
                             return '满意'
                         }
                        if (row.satisfaction == "3"){
                            return '一般'
                        }
                        if (row.satisfaction == "5"){
                            return '不满意'
                        }
                        return  "未评价";
                    }

                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.serviceId + '\')"><i class="fa fa-edit"></i>通话详情</a> ');

                        return actions.join('');
                    }


                }]
        };
        $.table.init(options);
    });
</script>
<style>
    .select-list li{
        display: flex;
    }
</style>
</body>
</html>